/* 平台按需加载组件 */
import {
  Layout,
  Menu,
  Row,
  Col,
  Card,
  Form,
  Dropdown,
  Select,
  Button,
  Checkbox,
  Tabs,
  Tag,
  Input,
  InputNumber,
  DatePicker,
  TimePicker,
  Radio,
  Tooltip,
  Space,
  Steps,
  Divider,
  Descriptions,
  Alert,
  Result,
  Statistic,
  Popconfirm,
  Popover,
  Table,
  Avatar,
  List,
  Progress,
  Switch,
  Modal,
  Upload,
  Rate,
  ConfigProvider,
  Empty,
  Spin,
  Drawer,
  PageHeader,
  Carousel,
  Badge,
  Tree,
  Collapse,
  Slider,
  Anchor,
  Affix
} from 'ant-design-vue';
import { default as STable, setLicenseKey } from '@surely-vue/table';
import * as Icons from '@ant-design/icons-vue';
import { Splitpanes, Pane } from '@/components/split-panes/index';
import AvicAutoCode from '@/components/auto-code/index';
import Viewer from 'v-viewer';
// surely-vue授权
setLicenseKey(
  // eslint-disable-next-line max-len
  '84c4ab3781ef44bbc82c858712d5b4c8T1JERVI6MTAwMDUxLEVYUElSWT00ODgxNTEzNjAwMDAwLERPTUFJTj1zdXJlbHkuY29vbCxVTFRJTUFURT0xLEtFWVZFUlNJT049MQ=='
);
export function registerComponents(app) {
  app
    .use(STable)
    .use(Layout)
    .use(Menu)
    .use(Row)
    .use(Col)
    .use(Card)
    .use(Form)
    .use(Dropdown)
    .use(Select)
    .use(Button)
    .use(Checkbox)
    .use(Tabs)
    .use(Tag)
    .use(Tree)
    .use(Input)
    .use(InputNumber)
    .use(DatePicker)
    .use(TimePicker)
    .use(Radio)
    .use(Tooltip)
    .use(Space)
    .use(Steps)
    .use(Divider)
    .use(Descriptions)
    .use(Alert)
    .use(Result)
    .use(Statistic)
    .use(Popconfirm)
    .use(Popover)
    .use(Table)
    .use(Avatar)
    .use(List)
    .use(Progress)
    .use(Switch)
    .use(Modal)
    .use(Upload)
    .use(Rate)
    .use(ConfigProvider)
    .use(Empty)
    .use(Spin)
    .use(Drawer)
    .use(PageHeader)
    .use(Badge)
    .use(Carousel)
    // .use(ProProvider)
    .use(Collapse)
    .use(Viewer)
    .use(Slider)
    .use(Anchor)
    .use(Affix)
    .component('AvicSplit', Splitpanes)
    .component('AvicPane', Pane)
    .component(
      'ProProvider',
      defineAsyncComponent(() => import('@/components/base-layouts/pro-provider'))
    )
    .component(
      'AvicIcon',
      defineAsyncComponent(() => import('@/components/icon/index.vue'))
    )
    .component(
      'AvicModal',
      defineAsyncComponent(() => import('@/components/modal/index.vue'))
    )
    .component(
      'AvicTreeSelect',
      defineAsyncComponent(() => import('@/components/tree-select/AvicTreeSelect.vue'))
    )
    .component(
      'PageContainer',
      defineAsyncComponent(() => import('@/components').then((res) => res.PageContainer))
    )
    .component(
      'TransformVnode',
      defineAsyncComponent(() => import('@/components').then((res) => res.TransformVnode))
    )
    .component(
      'AvicTable',
      defineAsyncComponent(() => import('@/components/table/index.vue'))
    )
    .component(
      'AvicDictTag',
      defineAsyncComponent(() => import('@/components/dict-tag/index.vue'))
    )
    .component(
      'AvicCommonSelect',
      defineAsyncComponent(() => import('@/components/common-select/index.vue'))
    )
    .component(
      'AvicUploader',
      defineAsyncComponent(() => import('@/components/file-upload/index.vue'))
    )
    .component('AvicAutoCode', AvicAutoCode)
    .component(
      'AvicExcelImport',
      defineAsyncComponent(() => import('@/components/excel-import/index.vue'))
    )
    .component(
      'AvicModalSelect',
      defineAsyncComponent(() => import('@/components/modal-select/index.vue'))
    )
    .component(
      'AvicRowEdit',
      defineAsyncComponent(() => import('@/components/row-edit/index.vue'))
    )
    .component(
      'AvicBpmFilter',
      defineAsyncComponent(() => import('@/components/bpm-filter/index.vue'))
    )
    .component(
      'AvicAdvancedQueryButton',
      defineAsyncComponent(() => import('@/components/advanced-query-button/index.vue'))
    )
    .component(
      'AvicNumberRange',
      defineAsyncComponent(() => import('@/components/number-range/index'))
    )
    .component(
      'AvicSecretSelect',
      defineAsyncComponent(() => import('@/components/secret-select/AvicSecretSelect.vue'))
    );
  // 全局使用图标，遍历引入
  const icons: any = Icons;
  Object.keys(icons).forEach((key) => {
    // 平台默认仅挂载线条图标，实现和双色图标自行按需引入
    const svgName = icons[key].displayName;
    if (svgName && svgName.includes('Outlined')) {
      app.component(key, icons[key]);
    }
  });
}
